package org.hredu.util;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class Config {
	private String ip="127.0.0.1";
	private String port="3306";
	private String user="root";
	private String pass="root";
	private String database="ban_hang";
	private String fileconfig="hreduconfig.properties";
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getPort() {
		return port;
	}
	public void setPort(String port) {
		this.port = port;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getPass() {
		return pass;
	}
	public void setPass(String pass) {
		this.pass = pass;
	}
	public String getDatabase() {
		return database;
	}
	public void setDatabase(String database) {
		this.database = database;
	}
	public String getFileconfig() {
		return fileconfig;
	}
	public void setFileconfig(String fileconfig) {
		this.fileconfig = fileconfig;
	}
	public Config(){
		try {
			String dir = System.getProperty("user.dir");
			FileInputStream fileInputStream = new FileInputStream(new File(dir+"/"+fileconfig));
			Properties properties = new Properties(System.getProperties());
			properties.load(fileInputStream);
			ip=properties.getProperty("ip");
			port=properties.getProperty("port");
			user=properties.getProperty("user");
			pass=properties.getProperty("pass");
			database=properties.getProperty("database");
		} catch (Exception e) {
			// TODO: handle exception
		}		
	}
}
